package com.qf.dao;

import com.qf.pojo.User;
import org.apache.ibatis.annotations.*;

public interface UserDao {
    @Insert("INSERT INTO `t_users` (`Name`,`PASSWORD`,`sex`,`birthday`,`registTime`)  VALUES (#{name},#{password},#{sex},#{birthday},#{registTime})")
    @SelectKey(keyProperty = "id",keyColumn = "id",resultType = int.class,before = false,statement = " SELECT LAST_INSERT_ID()")
    int addUser(User user);

    @Delete(" DELETE FROM `t_users` WHERE `id`=#{id}")
    int deleteUser(int id);

    @Update("UPDATE `t_users` SET `NAME`=#{name},`PASSWORD`=#{password},`sex`=#{sex} WHERE `id`=#{id}")
    void updateUser(User user);


    @Select("SELECT * FROM `t_users` WHERE `id`=#{id}")
    User selectById(int id);
}
